<template>
  <div class="visual_data">
    <div class="charts_box-btn">
      <el-button icon="el-icon-back" @click="backBtnClick">返回</el-button>
    </div>
    <div class="ecahrts sum"></div>
    <div class="ecahrts cfsum"></div>
    <div class="ecahrts pie"></div>
    <div class="ecahrts comment"></div>
  </div>
</template>
<script>
export default {
  mounted() {
    this.getOption();
  },
  methods: {
    /**
     * 返回上一个页面
     */
    backBtnClick() {
      window.history.back();
    },
    echartsSum() {
      this.$axios.get("/admin/visual/sum/", {}).then((res) => {
        const dom = document.querySelector(".sum");
        const myChart = echarts.init(dom);

        const option = res.data.option;

        myChart.setOption(option);
      });
    },
    echartscFSum() {
      this.$axios.get("/admin/visual/cfsum/", {}).then((res) => {
        const dom = document.querySelector(".cfsum");
        const myChart = echarts.init(dom);

        const option = res.data.option;

        myChart.setOption(option);
      });
    },
    echartsPie() {
      this.$axios.get("/admin/visual/pie/", {}).then((res) => {
        const dom = document.querySelector(".pie");
        const myChart = echarts.init(dom);

        const option = res.data.option;

        myChart.setOption(option);
      });
    },
    echartsComment() {
      this.$axios.get("/admin/visual/comment/", {}).then((res) => {
        const dom = document.querySelector(".comment");
        const myChart = echarts.init(dom);

        const option = res.data.option;

        myChart.setOption(option);
      });
    },
    getOption() {
      this.echartsSum();
      this.echartscFSum();
      this.echartsPie();
      this.echartsComment();
    },
  },
};
</script>

<style lang="scss" scoped>
.visual_data {
  width: 100%;
  height: 200%;
  background: #fff;
}
.ecahrts {
  height: 350px;
  width: 80%;
  margin: 0 auto;
  margin-bottom: 100px;
}
</style>
